<?php //pack11class

class TablePropertiesShortHeader extends Module {

    public $currency;
    public $showprice;

    public function setup() {
        //$this->addChild($this->generateCurrencySelect());
        //$this->addChild($this->generatePriceCheck());
        $this->currency=Template::html($this->generateCurrencySelect());
        $this->showprice=Template::html($this->generatePriceCheck());
    }

    private function generateCurrencySelect() {
        $select=new SelectInput;
        $currencies=CurrencyManager::getCurrencies();
        if(!$currencies) {
            return false;
        }
        foreach($currencies as $currency) {
            $option=new SelectOption;
            $option->label=$currency->label;
            $option->value=$currency->id;
            $option->selected=($currency==CurrencyManager::currentCurrency())? SelectOption::SELECTED:"";
            $select->addChild($option);
        }


        $select->property_name="currency";
        $select->setID("TableProperties_currency");
        $select->events=str_replace('\"', '"', "onChange=\"TablePropertiesPopup.setCurrency(this,true);\"");
        $select->class="select";
        $select->setClass("ObjectsListProperties");
        $select->lamp_class="hidden";
        return $select;
    }

    private function generatePriceCheck() {
        $item=new CheckBoxInput;
        $item->property_name="showPrice";
        //$item->label=LabelManager::getLabel("showPrice_checkbox_label");
        $item->label=LabelManager::getLabel("price_sqm");
        $item->checked=(ObjectsManager::getShowPrice())? CheckBoxInput::CHECKED:"";
        $item->value=(ObjectsManager::getShowPrice())? "1":"0";
        $item->formid="TableProperties";
        $item->events=str_replace('\"', '"', "onClick=\"Javascript:TablePropertiesPopup.setShowPrice(this,true);\"");
        //$item->addStyle("margin-left","60px");
        $item->addStyle("position","relative");
        $item->addStyle("display","inline");
        $item->setClass("TablePropertiesShowPrice");
        return $item;
    }

}
?>
